home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7563 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: news.ichange.com!newsmaster
  2. From: Jesse Liberty <jl@staff.ichange.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: what happens w/delete called twice ?
  5. Date: Fri, 23 Feb 1996 17:40:13 -0500
  6. Organization: AT&T
  7. Message-ID: <312E424D.67F8@staff.ichange.com>
  8. References: <kcc.423.0EE12CF6@interaccess.com>
  9. NNTP-Posting-Host: 140.244.99.60
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (Win95; I)
  14. CC: jl@staff.ichange.com
  15.  
  16. kcc wrote:
  17.  
  18. >         Can someone tell me... what happens when delete is called twice for the same [pointer]?
  19.  
  20. The answer is that your program crashes right away... if you are lucky.  If you are not lucky, it crashes later.
  21.  
  22. When you delete a pointer, set it to zero. It is then safe to delete it again.  
  23.  
  24.     delete struct_p;
  25.  
  26.     struct_p = 0;       // add this to your code
  27.  
  28.     delete struct_p;       // now safe, has no affect.
  29.  
  30.  
  31.  
  32. -- 
  33. Jesse Liberty    jl@staff.ichange.com
  34. AT&T             CIS: 72241,72
  35. Teach Yourself C++ In 21 Days  SAMS 1994
  36. Teach Yourself MORE C++ In 21 Days SAMS 1995
  37.